<template>
  <div class="meView">
    <div class="header">
      <div class="left">
        <van-icon name="setting-o" size="25" />
      </div>
      <div class="right">
        <van-icon name="bell" size="25" badge="2" />
        <van-icon name="share-o" size="25" style="margin-left: 20px" />
      </div>
    </div>
    <div class="likeheader"></div>
    <div class="information">
      <div class="top">
        <div class="left">
          <div class="avatar">
            <van-image
              width="82"
              height="82"
              round
              src="https://tx1.douguo.com/upload/photo/1/1/1/70_3309d49bb18e78ff5ed8f20c21b0d87b.png"
              lazy-load
            />
          </div>
        </div>
        <div class="right">
          <div class="nickname">缓缓的蝎子很陌生</div>
          <div class="lv">LV.1</div>
          <div class="complete" @click="toMeEdit">✏️ 补全资料 +500经验</div>
        </div>
      </div>
      <div class="sub">
        <div>厨娘</div>
        <div>豆龄 0.1岁</div>
        <div>IP地址 广东</div>
      </div>
      <div class="signature">吃货不是在吃的就是在去吃的路上，没时间写签名</div>
    </div>
    <div class="first-navBox">
      <div class="first-nav" @click="toMeFollow">
        <div class="number">{{ follows.length }}</div>
        <div class="word">关注</div>
      </div>
      <div class="first-nav" @click="toMeFans">
        <div class="number">0</div>
        <div class="word">粉丝</div>
      </div>
      <div class="first-nav">
        <div class="number">0</div>
        <div class="word">被收藏</div>
      </div>
      <div class="first-nav">
        <div class="number">0</div>
        <div class="word">被学做</div>
      </div>
      <div class="first-nav">
        <div class="number">38</div>
        <div class="word">经验值</div>
      </div>
    </div>
    <div class="vip-signIn">
      <div class="vip">
        <div class="left">
          <van-icon name="smile-o" size="28" color="#ffe5a6" />
        </div>
        <div class="right">
          <div class="title">尊享VIP卡</div>
          <div class="sub">
            <div class="word">科学饮食轻松带飞</div>
            <van-icon name="arrow" size="10" color="white" />
          </div>
        </div>
      </div>
      <div class="line"></div>
      <div class="signIn">
        <div class="left">
          <van-icon name="gold-coin-o" size="28" color="#ffe5a6" />
        </div>
        <div class="right">
          <div class="title">签到领钱</div>
          <div class="sub">
            <div class="word">做任务赢现金</div>
            <van-icon name="arrow" size="10" color="white" />
          </div>
        </div>
      </div>
    </div>
    <div class="sec-navBox">
      <div class="sec-nav" @click="toMeLists">
        <van-icon name="bag-o" size="22" />
        <div class="word">
          采购清单{{
            shoppingList.length > 0 ? `(${shoppingList.length})` : ""
          }}
        </div>
      </div>
      <div class="sec-nav">
        <van-icon name="pending-payment" size="22" />
        <div class="word">钱包</div>
      </div>
      <div class="sec-nav">
        <van-icon name="coupon-o" size="22" />
        <div class="word">优惠券</div>
      </div>
      <div class="sec-nav">
        <van-icon name="label-o" size="22" />
        <div class="word">订单</div>
      </div>
      <div class="sec-nav">
        <van-icon name="clock-o" size="22" @click="toMeBrowsed" />
        <div class="word">历史记录</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import router from "@/router";
import { ref } from "vue";

const shoppingList = ref(
  JSON.parse(localStorage.getItem("shoppingList") || "[]")
);
const follows = ref(JSON.parse(localStorage.getItem("follow") || "[]"));

const toMeLists = () => {
  // console.log("toMeLists");
  router.push({
    name: "byRecipe",
  });
};

const toMeFollow = () => {
  // console.log("toMeFollow");
  router.push({
    name: "meFollow",
  });
};

const toMeFans = () => {
  // console.log("toMeFans");
  router.push({
    name: "meFans",
  });
};

const toMeEdit = () => {
  // console.log("toMeEdit");
  router.push({
    path: "meEdit",
  });
};

const toMeBrowsed = () => {
  // console.log("toMeBrowsed");
  router.push({
    path: "meBrowsed",
  });
};
</script>

<style lang="scss" scoped>
.meView {
  padding: 0 16px;

  .header {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 50px;
    background-color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .left {
      margin-left: 25px;
    }

    .right {
      margin-right: 25px;
      display: flex;
      align-items: center;
    }
  }

  .likeheader {
    height: 50px;
  }

  .information {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;

    .top {
      display: flex;
      justify-content: space-between;
      margin-bottom: 15px;

      .left {
        .avatar {
          width: 82px;
          height: 82px;
          border-radius: 50%;
          cursor: pointer;
        }
      }

      .right {
        display: flex;
        flex-direction: column;

        .nickname {
          // font-weight: bold;
          font-size: 18px;
          margin-bottom: 5px;
        }

        .lv {
          font-size: 14px;
          font-style: italic;
          color: #f8d24e;
          margin-bottom: 5px;
          font-weight: bold;
        }

        .complete {
          width: 227px;
          text-align: center;
          height: 36px;
          line-height: 36px;
          border-radius: 18px;
          background-color: #ffc536;
          font-size: 16px;
          font-weight: bold;
          cursor: pointer;
        }
      }
    }

    .sub {
      display: flex;
      margin-bottom: 5px;

      div {
        font-size: 14px;
        font-weight: bold;
        margin-right: 10px;
      }
    }

    .signature {
      font-size: 14px;
    }
  }

  .first-navBox {
    display: flex;
    justify-content: space-between;
    padding: 0 5px;
    margin-bottom: 15px;

    .first-nav {
      width: 40px;
      display: flex;
      flex-direction: column;
      align-items: center;
      font-size: 13px;
      cursor: pointer;

      .number {
        margin-bottom: 10px;
        color: #000;
        font-weight: bold;
      }

      .word {
        color: #999;
      }
    }
  }

  .vip-signIn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    width: 100%;
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    margin-bottom: 15px;

    > div {
      width: 49%;
      display: flex;
      align-items: center;
      cursor: pointer;

      .left {
        margin-left: 10px;
        width: 24px;
        height: 24px;
        background-color: #f5cf81;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 20px;
      }

      .right {
        display: flex;
        flex-direction: column;
        margin-left: 10px;

        .title {
          margin-bottom: 5px;
          font-weight: bold;
          color: #ffe5a6;
          font-size: 14px;
        }

        .sub {
          display: flex;
          align-items: center;
          font-size: 12px;
          color: white;

          .word {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            margin-right: 3px;
          }
        }
      }
    }

    .vip {
      .word {
        width: 80px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }

    .line {
      width: 0.5%;
      height: 22px;
      background-color: #ffe5a6;
    }
  }

  .sec-navBox {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;

    .sec-nav {
      width: 20%;
      // min-width: 20%;
      display: flex;
      flex-direction: column;
      align-items: center;
      cursor: pointer;

      .word {
        margin-top: 10px;
        font-size: 12px;
        white-space: nowrap;
      }
    }
  }
}
</style>
